# Contributor: Peter Bui <pnutzh4x0r@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=supervisor
pkgver=4.2.5
pkgrel=4
pkgdesc="system for controlling process state under UNIX"
url="http://supervisord.org/"
arch="noarch"
license="BSD-4-Clause AND BSD-3-Clause-Clear"
# setuptools is a runtime dependency,
# see 4a92a58b46bf23924e243fb36bf3ba769a476178
depends="python3 py3-setuptools"
makedepends="py3-gpep517 py3-wheel"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc supervisor-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/Supervisor/supervisor/archive/$pkgver.tar.gz
	supervisord.conf
	supervisord.initrd
	supervisord.logrotate"

# secfixes:
#   4.1.0-r0:
#     - CVE-2019-12105
#   3.2.4-r0:
#     - CVE-2017-11610

build() {
	gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" .dist/*.whl
	install -Dm600 "$srcdir/supervisord.conf" "$pkgdir/etc/supervisord.conf"
	install -Dm755 "$srcdir/supervisord.initrd" "$pkgdir/etc/init.d/supervisord"
	install -Dm644 "$srcdir/supervisord.logrotate" "$pkgdir/etc/logrotate.d/supervisord"
}

sha512sums="
54feb6f9779326aad90f00a88097f2e68a3aefebfa2529782768c097f28d4d94583b345da6a95593f92bdf04177d61761e4f9e1f0bb48afa4abee005a0a078d1  supervisor-4.2.5.tar.gz
efdb2dba28cf310aebd730a9096838c5b879c457e4961c6b54d4da1db7238300f584cd714ca48a71ba891f780d819ee719c3b3dbbf92eb1213794833544f01b6  supervisord.conf
7f7c51239c2360c4d03e1167e90650e0474ce8a0ca79c5d491f5f04a78eb95c343ed25d81983cde2f82535420e9b663cde532665114124b06a98fd7d08410416  supervisord.initrd
881fd0893280cb5053f56128838af51b6c79d715559e7b04a268102fd7b6121c99ff4411ed7f443f21232146925d40e1fbe269e5fcefa3f86fa35ba9d3625193  supervisord.logrotate
"
